-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java reflection to automatically import android plugins into MainActivity.java #3054
Closed
SmileyJames
wants to merge
15
commits into
ionic-team:master
from
SmileyJames:java-plugin-reflection
Closed
Java reflection to automatically import android plugins into MainActivity.java #3054
SmileyJames
wants to merge
15
commits into
ionic-team:master
from
SmileyJames:java-plugin-reflection
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use read-installed package to resolve plugins from all dependencies, not just local ones.
Kept encountering this error when compiling: node_modules/commander/typings/index.d.ts:26:25 - error TS2689: Cannot extend an interface 'NodeJS.EventEmitter'. Did you mean 'implements'? Had the add node/types specifically for version 12 tj/commander.js#787 DefinitelyTyped/DefinitelyTyped@c47a34e#r36559684
Remeber what we have seen because back refereences exist
So that node 10 is supported
We stopped using .flat()
No need to manually edit MainActivity.java
Java reflection means that overriding onCreate is no longer required
Choose the most recent version Warn about ignored packages
Only call getPlugins once Check if file exists before reading file Inform user with a spinner in the cli
Closing this as well (see #3040 (comment)). Please track this feature here: #3266 Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch builds on my other pull request: #3040
Plugins are recursively found (other PR) then their java class paths are written to a json file. BridgeActivity then reads the json file and uses Java reflection to import and add the android plugin to the build.
The advantage of using Java reflection is that no manual editing of MainActivity.java is never required, as it currently is as described here: https://capacitor.ionicframework.com/docs/plugins/android/#export-to-capacitor. Capacitor would be able to convert a PWA to an android and ios app in a completely automated fashion.
This change is completly backwards compatible. Overriding onCreate in MainActivity.java will "opt out" of Java reflection, if you want to manually add plugins as before you can. Migration path is, keep doing what you are doing as before and no reflection will be used. Nothing changes for existing users.
It seems wise to seperate the concerns of these two PRs - if only to seperate discussion of the impact of these changes.